package com.patrol.service.impl;

import com.patrol.auth.dao.AdminUserDao;
import com.patrol.auth.pojo.AdminUser;
import com.patrol.service.UserInformationService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author 宋灿
 * @version 1.0
 * @description: TODO
 * @date 2021/8/13 11:13
 */
@Service
public class UserInformationServiceImpl implements UserInformationService {
    @Resource
    private AdminUserDao adminUserDao;
    @Override
    public AdminUser getUserInformation(String username){
        //使用findByUsername（）方法，判断userCheck是否为空（在数据库中是否存在）
        AdminUser userCheck = adminUserDao.findByUsername(username);
        //返回对象
        return userCheck;
    }
    @Override
    public boolean setUserInformation(AdminUser adminUser){
//        Integer check = adminUserDao.updateUser(adminUser, username);
        int i = adminUserDao.updateById(adminUser);
        return i == 1;
    }

    @Override
    public String getImgUrl(String username) {
        return adminUserDao.selectUserImgUrl(username);
    }
}
